<?php
/**
 * True Gallery Plugin Back-End Router
 *
 * @version 2.5
 * @author Alexey N. Brin (userxp@joomlaportal.ru)
 * @filename plugins.php
 * @package True Gallery
 * @copyright (C) 2008-2010 by joomlatune.ru
 * @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
 * 
 * If you fork this to create your own project, 
 * please make a reference to True Gallery someplace in your code 
 * and provide a link to http://www.joomlatune.ru
 *
 **/

defined('_VALID_MOS') or defined('_JEXEC') or die('Direct Access to this location is not allowed.');

class JTruePluginsRouterAdmin extends JoomlaTuneRouter
{
	function _default() {
		echo '<script>
		console.log( \'*******************\' );
		</script>';
		//JTruePluginsRouter::show();
		//$view = getUrlParam( 'view' );
		$name = getUrlParam( 'plugin' );
		//$task = getUrlParam( 'task', null );
		
		if( $name && TG_AJAX ) {
			$data = getUrlParam( 'data', null );
			$plugin = &getPlugin( $name, $data );
			if( method_exists( $plugin, $task ) && $task!=='load' && $task!=='view' && $task!=='_default' ) {
				return $plugin->$task();
			}
			
		} else if( !TG_AJAX ) {
			$this->view();
		}
		
	} //_default
	
	function view( $tmpl = 'admin.plugins') {
		$db = &getDBO();
		
		$where = ''; // may be I would using filter? :)
		$query = 'SELECT COUNT(id) FROM '.TG_TBLPREFIX.'_plugins AS a '.$where;
		$db->setQuery( $query );
		$total = $db->loadResult();
		
		//$query = 'SELECT * FROM '.TG_TBLPREFIX.'_plugins AS a '.$where;
		//$db->setQuery( $query );
		//$plugins = &JTunePlugins::getInstance(TG_TBLPREFIX);
		
		include_once JTuneLayout::getFile( $tmpl );
	} //view
	
	
} //JTruePluginsRouterAdmin

class JTruePluginsRouterSite extends JoomlaTuneRouter
{
	function _default() {
		// emptiness :)
	} // _default
	
} //JTruePluginsRouterSite
?>
